package com.zzf.concurrent.example.sync.bean;

import com.zzf.concurrent.example.util.TimeUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author GaoFeng2017
 * @date 2019/8/6 9:31
 */
@Slf4j
public class DeadLock implements Runnable{

    private final Object LOCK = new Object();

    private OtherService otherService;


    @Override
    public void run() {
        while (true) {
            s1();
            TimeUtil.sleep(1);
        }
    }

    private void s1() {
        synchronized (LOCK) {
            log.info("s1=================");
            otherService.m2();
        }
    }

    public void s2() {
        synchronized (LOCK) {
            log.info("s2================");
        }
    }

    public Object getLOCK() {
        return LOCK;
    }

    public void setOtherService(OtherService otherService) {
        this.otherService = otherService;
    }
}
